#!/bin/sh

for file in tests/[0-9]*-*.tool
do

	mainClassFile=`awk '{if($1 == "object") print $2}' < $file`
	scala -classpath .:bin:lib/cafebabe.jar tool.Main $file 2> /dev/null > /dev/null

	if [ -e $mainClassFile.class ]; then
		java $mainClassFile > res1
		rm *.class

		java -jar toolc-reference.jar $file
		java $mainClassFile > res2
		rm *.class
		diff res1 res2 > result

		rm -f res1
		rm -f res2

		if [ ! -s result ]; then
			echo "$file : CORRECT :)"
		else
			echo "$file : FAILED :("
		fi
	else
		echo "Couldn't compile : $file"	
	fi
done;
